<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>3.最应该使用v-if的场景</title>
    <!-- 引入Vue -->
    <script type="text/javascript" src="../../js/vue.js"></script>
  </head>
  <body>
    <!-- 准备好一个容器-->
    <div id="demo">
      <h1 v-if="person.age">真实年龄：{{person.age.realAge}}</h1>
      <button @click="getNetWorkData">获取网络数据</button>
    </div>

    <script type="text/javascript">
      new Vue({
        el:'#demo',
        data:{
          person:{}
        },
        methods: {
          getNetWorkData(){
            this.person = {
              age:{
                foreignAge:29,
                realAge:45
              }
            }
          }
        },
      })
    </script>
  </body>
</html>